package org.garbagecan.quartzstudy;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Properties;

import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;

public class TestUtil {

	public static Scheduler getScheduler() throws Exception {
		Properties prop = new Properties();
		prop.load(TestUtil.class.getResourceAsStream("/org/garbagecan/quartzstudy/quartz.properties"));
		SchedulerFactory sf = new StdSchedulerFactory(prop);
		Scheduler scheduler = sf.getScheduler();
		return scheduler;
	}
	
	public static String getDateTime() {
		Calendar cal = Calendar.getInstance();
		return format(cal.getTime());
	}
	public static Date parse(String s) throws ParseException {
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = df.parse(s);
		return date;
	}

	public static String format(Date date) {
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return df.format(date);
	}
}
